/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.main.zlw.zlwaudiorecorder;

import com.zlw.main.recorderlib.RecordManager;
import com.zlw.main.recorderlib.recorder.RecordConfig;
import com.zlw.main.recorderlib.recorder.RecordService;
import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import ohos.app.Environment;
import ohos.media.audio.AudioStreamInfo;
import org.junit.Before;
import org.junit.Test;

import java.util.Locale;

import static org.junit.Assert.assertEquals;

public class ExampleOhosTest {
    private RecordManager recordManager;
    @Test
    public void testBundleName() {
        final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
        assertEquals("com.main.zlw.zlwaudiorecorder", actualBundleName);
    }

    @Before
    public void set(){
        recordManager = RecordManager.getInstance();
        recordManager.changeFormat(RecordConfig.RecordFormat.PCM);
        recordManager.changeRecordConfig(recordManager.getRecordConfig().setSampleRate(16000));
        recordManager.changeRecordConfig(recordManager.getRecordConfig().setChannelConfig(AudioStreamInfo.ChannelMask
                .CHANNEL_IN_MONO));
        recordManager.changeRecordConfig(recordManager.getRecordConfig().setEncodingConfig(AudioStreamInfo.EncodingFormat
                .ENCODING_PCM_16BIT));
    }

    @Test
    public void getFormat() {
        assertEquals(RecordConfig.RecordFormat.PCM.getExtension(), RecordService.getRecordConfig().getFormat().getExtension());
    }

    @Test
    public void getSampleRate() {
        assertEquals(16000,RecordService.getRecordConfig().getSampleRate());
    }

    @Test
    public void getChannelConfig() {
        assertEquals(AudioStreamInfo.ChannelMask
                .CHANNEL_IN_MONO,RecordService.getRecordConfig().getChannelConfig());
    }

    @Test
    public void getEncodingConfig() {
        assertEquals(AudioStreamInfo.EncodingFormat
                .ENCODING_PCM_16BIT,RecordService.getRecordConfig().getEncodingConfig());
    }
}